home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 28 / Commodore_Free_Issue_28_2009_Commodore_Computer_Club.d64 / aa notes < prev    next >
Text File  |  2023-02-26  |  12KB  |  452 lines

  1. u
  2.  
  3.  
  4. ****************
  5. * READERS CODE *
  6. ****************
  7. One of Commodore Free readers sent
  8. this application in it's for the
  9. commodore 16/plus 4 range of
  10. computers called AA timer, if you
  11. like these type in programs then let
  12. me know as the reader has some more.
  13.  
  14. AA Timer notes
  15.  
  16. lines:-
  17.  
  18. 10 - 110  REMarks about the program.
  19. Clear & Initialise Screen. Set max.
  20. Volume, people can then adjust their
  21. sets accordingly. Print instructions
  22. to test everything is working
  23. properly, Wait for user input.
  24.  
  25. 120 - 170 Discern user response and
  26. act accordingly. Self explanatory
  27. really, from above PRINT statements.
  28.  
  29. 180 - 260  Pressing any key in the
  30. menu above sends the user to this
  31. menu. As there is a sound test
  32. anyway, it isn't really necessary. It
  33. was a precursor to figuring out
  34. timings as I had to discover again
  35. from memory, due to the intro. to
  36. basic manual being long gone.  I
  37. still seek this, and the sequel/s...I
  38. left it in as it is in line with the
  39. spirit of the program. May be useful
  40. for further study.
  41.  
  42. SERIOUS NOTE:  Here I must make
  43. another point that it is dangerous to
  44. watch time.  Not just because fellow
  45. workers consider it "skiving off
  46. work" but due to its effects on the
  47. mind.  People have become seriously
  48. ill due to watching time.  ...so I
  49. took up programming!
  50.  
  51. DEBUGGING:  With the above in mind
  52. here is a tip to stop the computer
  53. showing the count.
  54.  
  55. LIST310 put the cursor over the 0.
  56. And type "1" and press RETURN repeat
  57. with "2", 3, 4, 5,6,7
  58.  
  59. LIST310-318 (I always add one in the
  60. list for good measure)
  61.  
  62. 310 All you want is the first
  63. command.  So delete "Inst/Del" or
  64. space out all the rest after. and
  65. press RETURN.
  66.  
  67. 311 You already have the first
  68. command in the previous line, so
  69. delete it here. -And in all the
  70. following lines!)  The first command
  71. now should read x$=ti$. scrub out the
  72. ones after it.  Again you don't need
  73. the command after this line so delete
  74. all the others.  The command gives
  75. the computer something to calculate
  76. with and updates according to the
  77. current time which got reset to
  78. midnight "000000" on the appropriate
  79. key press to start the test.
  80.  
  81. 312  Here is nowhere we need to
  82. deviate from the pattern. Space/scrub
  83. out the whole line.  And from the
  84. usual place type the following
  85. command and press RETURN.
  86. IFX$=>3 ANDX$<7 THEN314
  87.  
  88. 313 we only need the print statement
  89. here so delete the rest.  By now
  90. there should on be the NEXT
  91. statement. And..
  92.  
  93. 314 we only need the NextJ.  You know
  94. what to do!
  95.  
  96. Testing the debugging:  Here we have
  97. 3 extra lines.  The computer must
  98. ignore these for the program to work.
  99.  And as we're only testing our
  100. efforts thus far, we may need them
  101. later. Hold shift down on the P of
  102. the PRINT statement. And press the
  103. key for inst.del. 4 times. Let go of
  104. these.  Type REM and press return
  105. key.  On all the lines.
  106. Run program.
  107.  
  108. The first thing I found was that I
  109. forgot to put inverted commas around
  110. the "3" and the "7".  And I think if
  111. I live to be programming at 120 years
  112. old, I'll still be forgetting this!
  113.  
  114. The second thing I found was that the
  115. computer takes no notice unless it is
  116. written exactly to original form.
  117. That is "000003" ... "000007" because
  118. it's a string not just a number!
  119. Finally it now takes 12 seconds
  120. because of the extra command.  It
  121. would be easier to change the printed
  122. statement from 10 to 12 than to mess
  123. about for next loop.  Or would it?
  124. Try changing this to a DO Loop! In
  125. the first part of debugging we have
  126. found The proof of the pudding is in
  127. the eating, but in this case the
  128. eating proved the programmer to be
  129. the pudding!  But no matter as this
  130. teaches us that you can't always get
  131. it right first time.  So lets
  132. continue.
  133.  
  134. Q. Will it work using ti$ instead of
  135. x$ ?
  136. The answer is yes, only we're up to
  137. 15 seconds on the count.
  138.  
  139. Now. LIST310-319 again change the
  140. following lines accordingly.
  141.  
  142. 310 DO
  143.  
  144. 317 LOOPUNTILX$=>10
  145. Now we need to take out the NEXT
  146. STATEMENT IN 314.  We will need to
  147. repeat line 313 with what I have in
  148. mind so go over to 313 and 314.
  149.  
  150. Now relist the required lines 310-319
  151.  
  152. 312 ifx$=>"000003 and x$<"000007"
  153. then ja%=1;elseja%=0
  154. Use the shift and inst. del keys to
  155. put the following in front of the
  156. existing lines 313 & 314
  157.  
  158. 313 ifja%=0then...
  159.  
  160. 314 if ja% =1 then ... (now delete
  161. everything after ";", in its place
  162. type "counting" and press return to
  163. store it.
  164. I don't ever have any luck with do
  165. loops.  I'm fully expecting the
  166. program to ignore my request to stop
  167. at 10, and proceed to infinity!
  168. There is a way out, firstly with run
  169. stop.  So it is safe to see if this
  170. will happen.  So run the program.
  171. Again the mismatch error in 317,
  172. corrected accordingly. It works,
  173. albeit requiring a slight
  174. modification.
  175. ADD to the end of 313, the semicolon
  176. ";" symbol, followed by inverted
  177. commas.  And 9 spaces, followed by 9
  178. arrow presses to the left. This takes
  179. away the horrible "   ing" on the
  180. screen at the end etc. Now the
  181. programmer is not so much the
  182. pudding! ie.  Run the program to test
  183. it.  It works! exit program and Save
  184. it. Small note: 
  185.  
  186. line240 refers to the original
  187. for/next loop, not the new do/loop.
  188.  
  189. <OPTIONAL>
  190. LIST310-325 at the ready prompt type
  191. 315 & press return, same for 316. As
  192. these lines aren't needed. Had the
  193. UNTIL command been missed, as I have
  194. been known to get into a mess with
  195. these. I would've put in: 315
  196. ifx$=>"000010"then320 The > symbol
  197. prevents any slight variation, more
  198. likely if using ti$ from causing an
  199. endless count.
  200.  
  201. <REMEMBER>
  202. WARNING:  DO NOT PLAY WITH NOR WATCH
  203. TIME!  It is only safe to glance on
  204. such rare occasions' as are needed.
  205.  
  206. 360 - 550  when the user escapes the
  207. previous menu and gets to here.
  208. There are 3 options.
  209. In the lines 500 to 530 these are
  210. reserved in case I ever want to add
  211. to the program.
  212. Lets look at the options.  Print
  213. statements 420&430 go along with this
  214. but serve the dual use of putting a
  215. space between functions and exit key.
  216.  This could easily be achieved in 440
  217. with the down arrow.
  218.  
  219. 390 & 470  The instruction to go to
  220. egg timer at line 1210 on pressing
  221. the corresponding key.  The code also
  222. gives away the order in which the
  223. program was written.  The original
  224. idea was to provide a system to count
  225. for any-one undertaking exercises
  226. like Pilates or Yoga or whatever
  227.  
  228. Mute Point: 
  229. Much has been said in recent times
  230. about the annoyance of "Spaghetti
  231. coding", in this case the ability to
  232. go with how I felt was liberating.
  233. Giving a sense that I am doing this
  234. for fun, not out of some laborious
  235. obligation.  And so what if no-one
  236. else can read it, they'll have to
  237. come to me!
  238.  
  239. Now though I'm in two minds.  Do I
  240. follow the paper page for page or
  241. jump two pages to 1210 the way the
  242. choice is listed?  ...It makes more
  243. sense to keep to the same page for
  244. this purpose.
  245.  
  246. 550 tells the computer if you have
  247. any other key press than the options
  248. given.  Ignore it and go back to wait
  249. for another one.
  250.  
  251. 560 Interval beeps (key press 3)
  252.  
  253. 570 - 640 Setting up sub menu, self
  254. explanatory.
  255.  
  256. 650 Sets time to midnight, the only
  257. logical start point. oddly enough
  258. there is a DO without a LOOP.  Can
  259. You see why 1.  The computer never
  260. notices, I haven't once received a DO
  261. WITHOUT LOOP message!  And 2.  What
  262. would need changing to incorporate
  263. this as a full LOOP?  (And don't say
  264. "get a better programmer" or I'll
  265. cry!)
  266.  
  267. 660 look for a key press, but don't
  268. wait for one!  The difference being
  269. the omission of the IFA$="" (NOTHING,
  270. No Key Press) Then Jump back to this
  271. line.  The omission is quite correct
  272. for this purpose.
  273.  
  274. 670 if random isn't chosen. or
  275. switched off there are specifics for
  276. the sound command at the end of the
  277. count.  And so the computer must skip
  278. the following three lines that give
  279. random parameters.  (experiment with
  280. this all you want).  Of course if
  281. random is on then the reverse is
  282. true.
  283.  
  284. 705 In testing I seemed to get all
  285. kinds of numbers -testable by adding
  286. a print statement at production of
  287. sound.  ?"a";a ...etc.
  288.  
  289. 710 makes sure Random is on or off,
  290. and so only the parameters 0 and 1
  291. are used.
  292.  
  293. 720 mute function, if phone rings to
  294. save stopping program.  This will
  295. order the program to jump to 880
  296. where VOLume on/off is decided,
  297. followed by the appropriate print.
  298. then returned at 900 to -
  299.  
  300. 730 - 910 checks relevant parts to
  301. see if they need altering, carries
  302. them out and returns for more.  The
  303. engine room so to speak.  Can you
  304. find where the duration is set?, bear
  305. in mind that this would be at 0
  306. therefore produce a constant and
  307. annoying beep, if not set ahead of
  308. the beep.  800&810 make it possible
  309. for the alarm to go off at the
  310. correct moment.
  311.  
  312. <DEBUGGING>
  313. 840 Why not goto650 and omit the
  314. extra TI$ statement FROM 840?Too many
  315. RETURNs, change the preceding returns
  316. of the sub-menu to go to the last
  317. RETURN of the type.  In this case
  318. change870 to goto910 This way it will
  319. be easier to see where the menu of
  320. type ends.  More useful in larger
  321. programs.  Reduces "Spaghetti".
  322.  
  323. 850 Appears to be a line left for
  324. debugging in building.  As nothing I
  325. can see refers to it, and everything
  326. skips it.  It can be deleted to avoid
  327. later confusion.
  328.  
  329. DO's and Dont's!
  330. If you wished to LOOP as mentioned
  331. earlier.  Instead of Goto660, which
  332. if you've followed the above is now
  333. only820 as this does not reset time.
  334. In this case it may be better just to
  335. delete the DO as this menu isn't
  336. really designed for it.
  337. Finally, don't confuse keypress "X"
  338. with variable x.
  339.  
  340. 1000 The STOP WATCH menu.
  341. A simple Start - Stop sub-menu.  It's
  342. easy to press "S" to show time even
  343. with the line added to show when the
  344. counter is started.  The rest seems
  345. self explanatory.
  346.  
  347. NOSTALGIA:  I remember the "An
  348. Introduction to BASIC part 1" has a
  349. program with a timer that uses TI to
  350. test and measure reflexes (Do not
  351. confuse with the clock variable TI$),
  352. I've been longing to find a copy of
  353. this book and the sequel which I
  354. would've loved to own.  Not least
  355. because it would enhance this and
  356. future programs in this field.
  357.  In trying to recreate this from dead
  358. reckoning and "memory" (hilarious
  359. after 20 odd years!), I came up with
  360. the following which can stand alone
  361. or be added to the existing program.
  362. If you do add it.  Also change lines
  363.  
  364. 420 print" 4 - Reflex Timer"
  365. and
  366. 500  IFa$="4"then1540
  367. and
  368. 1720 GOTO370
  369.  
  370. 1550 REM *REFLEX TIMER*             
  371.  
  372. 1560 VOL8                           
  373.  
  374. 1570 PRINT"clrhome      REFLEX TIMER
  375. "       
  376. 1580 PRINT"down WAIT FOR BEEP"      
  377.     
  378. 1590 X=INT(RND(100)*750):REM PRINTX 
  379.  
  380. 1600 FOR J=0TOX:GETA$               
  381.  
  382. 1610 IFA$<>""THENPRINT"NO! WAIT FOR
  383. BEEP
  384. !":A$="":GOTO1590                   
  385.  
  386. 1620 NEXT J                         
  387.  
  388. 1630 SOUND1,300,10                  
  389.  
  390. 1640 TI$="000000":REM PRINTTI       
  391.  
  392. 1650 GETA$                          
  393.  
  394. 1660 REM PRINTTI                    
  395.  
  396. 1670 IFA$=""THEN1650                
  397.  
  398. 1680 PRINTTI                        
  399.  
  400. 1690 PRINT"ANOTHER GO Y/N?"         
  401.  
  402. 1700 GETA$:IFA$=""THEN1700          
  403.  
  404. 1710 IFA$<>"N"THEN1550              
  405.  
  406. 1720 END                            
  407.  
  408.  
  409. A challenge would be to make it two
  410. player using specific keys, and
  411. saying who wins.
  412. Also try adding a hall of fame.  I
  413. managed a fluke of 6 once.  Averaging
  414. about 19 or 20.  occasionally being
  415. as slow as 27.
  416.  
  417. 1590 randomises the wait for a beep.
  418. After REM is for debugging only.
  419.  
  420. 1600 set length of wait according to
  421. above.
  422.  
  423. 1610 check that nothing is pressed
  424. before beep.  If it is say so, and
  425. reset and importantly change time to
  426. wait.  This way person doesn't get
  427. used to delay.
  428.  
  429. 1620-30 obvious
  430.  
  431. 1640 This resets TImer!  Remembered
  432. late in build.
  433.  
  434. 1650-1680 Waits for key response and
  435. measures delay using TI.  It's not
  436. seconds, and as I don't have the book
  437. I don't know the rules of the timer.
  438. A bit of fun nonetheless.
  439.  
  440. 1690 - 1720 self explanatory.
  441.  
  442. 1210 Egg Timer
  443. Similar to stop watch, except set in
  444. advance how well you want your egg
  445. cooked. I can manage a full 9
  446. minutes!
  447. When time is up the program will beep
  448. until the user shows it due care and
  449. attentions by turning it off again.
  450.  
  451. ==================================
  452.